<?php if (!defined('THINK_PATH')) exit(); /*a:2:{s:65:"E:\phpCloud\ruanlink\public/../app/spadmin\view\domain\index.html";i:1732975732;s:54:"E:\phpCloud\ruanlink\app\spadmin\view\public\base.html";i:1732971886;}*/ ?>
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/>
		<title>后台管理系统</title>
		<!-- 样 式 文 件 -->
		<link rel="stylesheet" href="/assets/library/core/css/core.css?v=<?php echo config('version'); ?>" />
        
	</head>
    <!-- 代 码 结 构 -->
	
<body class="pear-container">
	<div class="layui-card">
		<div class="layui-card-body">
			<form class="layui-form" action="">
                <div class="layui-form-item layui-inline">
                    <label class="layui-form-label">域名</label>
                    <div class="layui-input-inline">
                        <input type="text" name="keywords" placeholder="域名" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item layui-inline">
                    <label class="layui-form-label">状态</label>
                    <div class="layui-input-inline">
                        <select name="status">
                            <option value="">选择状态</option>
                            <option value="1">启用</option>
                            <option value="2">禁用</option>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item layui-inline">
                    <button class="pear-btn pear-btn-md pear-btn-primary" lay-submit lay-filter="table-query">
                        <i class="layui-icon layui-icon-search"></i>
                        查询
                    </button>
                    <a href="<?php echo url('index'); ?>" class="pear-btn pear-btn-md">
                        <i class="layui-icon layui-icon-refresh"></i>
                        重置
                    </a>
                </div>
			</form>
		</div>
	</div>
	<div class="layui-card">
		<div class="layui-card-body">
			<table id="table-list" lay-filter="table-list"></table>
		</div>
	</div>
</body>

    <!-- 资 源 引 入 -->
		<script src="/assets/library/layui/layui.js?v=12<?php echo config('version'); ?>"></script>
		<script src="/assets/library/core/core.js?v=12<?php echo config('version'); ?>"></script>
		<script src="/static/js/qiniu.min.js?v=12<?php echo config('version'); ?>"></script>
	
	<script type="text/html" id="table-toolbar">
        <button class="pear-btn pear-btn-primary pear-btn-md" lay-event="batchadd">
			<i class="layui-icon layui-icon-add-1"></i>
			批量添加
		</button>
		<button class="pear-btn pear-btn-primary pear-btn-md" lay-event="add">
			<i class="layui-icon layui-icon-add-1"></i>
			新增
		</button>
		<button class="pear-btn pear-btn-danger pear-btn-md" lay-event="batchRemove">
			<i class="layui-icon layui-icon-delete"></i>
			删除
		</button>
	</script>
	<script type="text/html" id="table-bar">
        <button class="pear-btn pear-btn-primary pear-btn-sm" lay-event="edit"><i class="layui-icon layui-icon-edit"></i></button>
		<button class="pear-btn pear-btn-danger pear-btn-sm" lay-event="remove"><i class="layui-icon layui-icon-delete"></i></button>
	</script>
	
    
    <script type="text/html" id="table-status">
        <input type="checkbox" name="status" value="{{d.id}}" lay-skin="switch" lay-text="启用|禁用" lay-filter="table-status" {{ d.status== 1 ? 'checked' : '' }} />
    </script>
    <script type="text/html" id="user-group">
        {{#  if(d.id == 1 ){ }}
        <span class="layui-badge layui-bg-blue">超级管理员</span>
        {{# } else { }}

            {{# let tags = d.group?d.group.split(','):''}}
            {{# if (tags != ''){ }}
            {{# layui.each(tags, function(index, item){ }}
            <span class="layui-badge layui-bg-blue">{{ item }}</span>
            {{# }) }}
            {{# } }}
        {{# } }}
    </script>
        <script type="text/html" id="table-create_time">
        {{layui.util.toDateString(d.create_time, 'yyyy-MM-dd HH:mm')}}
    </script>
<script>
    layui.use(['table', 'form', 'jquery', 'common', 'laydate'], function () {
        let laydate = layui.laydate;
        let table = layui.table;
        let form = layui.form;
        let $ = layui.jquery;
        let common = layui.common;
        let cols = [
            [{
                type: 'checkbox'
            },
            {
                title: '域名',
                field: 'host',
                align: 'center',
                width: 200
            },
            {
                title: '中文解析',
                field: 'punycode',
                align: 'center',
                width: 200
            },
            {
                title: '绑定用户',
                field: 'user',
                align: 'center',
            },
            {
                title: '绑定方式',
                field: 'type',
                align: 'center',
            },
            {
                title: 'PV量',
                field: 'pv',
                align: 'center',
                width: 200
            },
            {
                title: 'UV量',
                field: 'uv',
                align: 'center',
                width: 200
            },
            {
                title: '状态',
                field: 'status',
                align: 'center',
                templet: '#table-status'
            },
            {
                title: '创建时间',
                field: 'create_time',
                align: 'center',
                templet: '#table-create_time'

            },
            {
                title: '操作',
                toolbar: '#table-bar',
                align: 'center',
                width: 130
            }
            ]
        ]

        table.render({
            elem: '#table-list',
            url: '<?php echo url("index"); ?>',
            parseData: function(res){ 
            return {
            "code": res.code, //解析接口状态
            "msg": res.message, //解析提示文本
            "count": res.data.total, //解析数据长度
            "data": res.data.data //解析数据列表
            }},
            page: true,
            cols: cols,
            skin: 'line',
            toolbar: '#table-toolbar',
            defaultToolbar: [{
                title: '刷新',
                layEvent: 'refresh',
                icon: 'layui-icon-refresh',
            }, 'filter']
        });
        form.on('submit(table-query)', function (data) {
            table.reload('table-list', {
                where: data.field
            })
            return false;
        });
        table.on('tool(table-list)', function (obj) {
            if (obj.event === 'remove') {
                common.remove(obj,"<?php echo url('batch'); ?>");
            }
            if (obj.event === 'edit') {
                common.modalo('<?php echo url("edit"); ?>?ids=' + obj.data['id'],'编辑');
            }
        });

        table.on('toolbar(table-list)', function (obj) {
            if (obj.event === 'add') {
                common.modalo('<?php echo url("add"); ?>','新增');
            }
            if (obj.event === 'refresh') {
                common.refresh();
            }
            if (obj.event === 'batchRemove') {
                common.batchRemove(obj,"<?php echo url('batch'); ?>");
            }
            if (obj.event === 'batchadd') {
                common.modalo("<?php echo url('batchadd'); ?>",'批量添加');
            }
        });
        form.on('switch(table-status)', function (data) {
            let loading = layer.load();
            let field = {};
            field['id']=data.value;
            field[data.elem.name] = data.elem.checked?"1":"0";
            $.ajax({
                url: '<?php echo url("change"); ?>',
                type: 'post',
                data: field,
                success: function (result) {
                    layer.close(loading);
                    if (result.code == 1) {
                        layer.msg('操作成功', {
								icon: 1,
								time: 1000
							})
                    } else {
                        layer.msg(result.msg, {
								icon: 2,
								time: 1000
							})
                    }
                }
            })
        });  

        
    })
</script>

</html>
